#ifndef __PXL_PKGUTIL_H
#define __PXL_PKGUTIL_H

struct PxlPackage_file
{
    char *         file_src;
    char *         file_dest;
    int            file_createOnly;
    int            file_executable;
    int            file_permanent;
    
    struct PxlPackage_file *next_file;
};

struct PxlPackage_touched
{
    char *         file_path;
    char *         file_hash;
    int            file_permanent;
    int            file_directory;
    
    struct PxlPackage_touched *next_file;
};

struct PxlPackage_postflight
{
    char **         post_command;
    int             post_count;
    char *          post_createsFile;
    int             post_nowait;
    
    struct PxlPackage_postflight *next_post;
};


struct PxlPackage_info
{
    char *         pkg_name;
    char *         pkg_id;
    char *         pkg_version;
    
    char *         pkg_url;
    char *         pkg_icon;
    char *         pkg_description;
    
    char *         pkg_updateurl;
    
    char *         pkg_scratchdir;
    
    struct PxlPackage_file *pkg_contents;
    struct PxlPackage_touched *pkg_installed;
    struct PxlPackage_postflight *pkg_postflight;
    struct PxlPackage_postflight *pkg_preremove;
};

extern struct PxlPackage_info * packageExtract(const char *package);

extern struct PxlPackage_info * parsePackageInfo(const char *manifestFile);
extern void freePackageInfo(struct PxlPackage_info *);

extern int installPackage(struct PxlPackage_info *pkg);
extern int writePackageInstalledManifest(const char *filename, struct PxlPackage_info *pkg);
extern int removePackage(struct PxlPackage_info *pkg, int remove_all);

#endif
